<?php 
	$id = $_GET['id'];
	$title = $_POST['title'];
	$content = $_POST['article'];
	$type = $_POST['type'];
	switch($type){
		case 'default':
			$typeName = '默认分类';
			break;
		case 'life':
			$typeName = '生活品味';
			break;
		case 'technology':
			$typeName = '技术相关';
			break;
		default:
			break;
	}
	include '../common/connect.php';
	if( empty($id) ){
		mysql_query("INSERT INTO new (title,content,type,typeName) VALUES ( '{$title}','{$content}','{$type}','{$typeName}')");
	}else{
		date_default_timezone_set('PRC');	//更改时区
		$time = date('Y-m-d H:i:s');
		mysql_query("UPDATE new SET title = '{$title}',content = '{$content}',type = '{$type}',typeName = '{$typeName}',time = '{$time}' WHERE id = '".$id."'");
	}
	mysql_close($con);
	header('location:newAdmin.php');
?>